package com.ccb.sc.common.modules.luxury.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccb.sc.common.modules.luxury.entity.LuxuryLogistics;
import com.ccb.sc.common.modules.luxury.enums.LuxuryLogisticsType;
import com.ccb.sc.common.modules.luxury.mapper.LuxuryLogisticsMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ken
 * @version 1.0
 * @date 2025/2/23 17:48
 */
@Service
public class LuxuryLogisticsService extends ServiceImpl<LuxuryLogisticsMapper, LuxuryLogistics> {

    public List<LuxuryLogistics> findByOrderId(String orderId) {
        return this.list(Wrappers.<LuxuryLogistics>lambdaQuery().eq(LuxuryLogistics::getOrderId, orderId));
    }

    public LuxuryLogistics findByOrderIdAndType(String orderId, LuxuryLogisticsType type) {
        return this.getOne(Wrappers.<LuxuryLogistics>lambdaQuery().eq(LuxuryLogistics::getOrderId, orderId)
                .eq(LuxuryLogistics::getType, type)
                .orderByDesc(LuxuryLogistics::getId)
                .last("limit 1"));
    }

}
